package soundcontrol;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.io.FileInputStream;

import java.io.IOException;
import java.net.InetAddress;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.ws.Endpoint;
import soundcontrol.gui.Main;
import soundcontrol.soap.SoundControlSoap;

/**
 *
 * @author Lianowar
 */
public class SoundControl {

    /**
     * @param args the command line arguments
     */
    
    public static Properties configFile = new Properties();
    public static Properties configGui = new Properties();
    
    public static boolean noGui;
    public static String port;
    
    public static void main(String[] args) {
        try {
            
            for (int i = 0; i < args.length; i++) 
            {   
               if(args[i].equals("-noGui"))
               {
                   noGui =  true;
               }
               else if(args[i].equals("-port") && args[i+1].length() > 1)
               {
                   port = args[i+1];
                   System.out.print(port);
               }
               i = i+1;
             } 
            
            // TODO code application logic here
            configFile = new Properties(); configFile.load(new FileInputStream(System.getProperty("user.home")+System.getProperty("file.separator")+"config.properties"));
            configGui = new Properties(); configGui.load(new FileInputStream(System.getProperty("user.home")+System.getProperty("file.separator")+"configgui.properties"));
            if(!noGui)
            {
            Main mainframe = new Main();
            mainframe.setVisible(true);
            }
            System.out.println("Soap Start auf IP: http://"+SoundControl.configGui.getProperty("IP")+":1337/soundcontrol");
            SoundControlSoap soap = new SoundControlSoap();
            Endpoint endpoint = Endpoint.publish("http://"+SoundControl.configGui.getProperty("IP")+":1337/soundcontrol", soap);
            System.out.println("IsPublished() "+endpoint.isPublished());
        } catch (IOException ex) {
            Logger.getLogger(SoundControl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
